package com.bw.shopping.adapter;

import android.view.View;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.TextView;

import com.blankj.utilcode.util.LogUtils;
import com.bw.mvvm_common.network.load.LoadImage;
import com.bw.shopping.R;
import com.bw.shopping.entity.ShoppingEnttiy;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import org.jetbrains.annotations.NotNull;

import javax.security.auth.callback.Callback;

/**
 * @author KK
 * @description:
 * @date :2021/10/21 20:01
 */
public class ShoppingAdapter extends BaseQuickAdapter<ShoppingEnttiy.DataBean, BaseViewHolder> {

    public ShoppingAdapter() {
        super(R.layout.item_shopping);
        addChildClickViewIds(R.id.lbtn,R.id.rbtn,R.id.item_chex);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder baseViewHolder, ShoppingEnttiy.DataBean dataBean) {

        ImageView im = baseViewHolder.findView(R.id.item_shopping_im);
        baseViewHolder.setText(R.id.item_shopping_title,dataBean.getGoods_sku());
        baseViewHolder.setText(R.id.item_shopping_tv,dataBean.getGoods_desc());
        baseViewHolder.setText(R.id.value,""+(dataBean.getGoods_count()));
        baseViewHolder.setText(R.id.item_shopping_money,"￥"+dataBean.getGoods_price());
        LoadImage.loadMatchImg(dataBean.getGoods_icon(),im);
        CheckBox checkBox = baseViewHolder.findView(R.id.item_chex);
        checkBox.setChecked(dataBean.isSelect);

        if(dataBean.isEditSelect()){
            checkBox.setVisibility(View.VISIBLE);
        }else {
            checkBox.setVisibility(View.GONE);
        }

    }



}
